package org.shangma.mapper;

import org.shangma.common.Good;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface GoodMapper {

    @Select("select id,good_name as goodName,good_price as goodPrice,good_stock as goodStock  from t_good where id=#{goodId}")
    Good findGoodById(int goodId);

    /**
     * 添加订单
     */
    @Insert("update t_good set good_stock=good_stock-#{stockNum} where id=#{goodId} ")
    void reduceStock(@Param("goodId") int goodId, @Param("stockNum") int stockNum);
}
